package org.example.ch04;

import java.util.Random;

/**
 * @author yang
 * @date 2024-03-14
 */
public class Thief{
    public void theft(Door door){
        if (door instanceof Warring){
            door.open();
            ((Warring) door).warring();
            int rand = new Random().nextInt(10)+1;
            if (rand >= 7){
                System.out.println("开始偷东西...");
            }else{
                System.out.println("盗窃失败，被抓了");
            }
        }else {
            door.open();
            System.out.println("开始偷东西...");
        }
    }
}
